/*
 * Projekt: GMU 2013 - Canny hranovy detektor OpenCL/CUDA
 * Autori: Pavel Nevrala - xnevra00 (xnevra00@stud.fit.vutbr.cz)
 *         Martin Jurak - xjurak02 (xjurak02@stud.fit.vutbr.cz)
 */
#pragma once

#include <CL/opencl.h>
#include "cannydetector.h"
#include "Errors.h"
/*
 * class CannyDetectorCL
 * Trida pro Cannyho hranovy detektor v OpenCL
 */
#define TYPE CV_32F

class CannyDetectorCL :
	public CannyDetector
{
public:
	// typ zarizeni, pouzije se pouze GPU
	typedef enum Device { CPU, GPU } device_t;

	CannyDetectorCL(Device device);	//deklarace konstruktoru
	~CannyDetectorCL(void);			//deklarace destruktoru
	
	/*
	 * Detekce hran
	 * @inImage - vstupni obraz
	 * @outImage - vystupni obraz
	 * @gaussMask - Gaussova maska
	 * @threshold - prah 
	 */
	virtual void detectEdges(ImageCL &inImage, ImageCL &outImage, GaussianMask &gaussMask, int threshold1, int threshold2);

private:
	cl_device_id deviceId;			//id zarizeni
	cl_uint maxWorkGroup;			//maximalni WorkGroup size
	cl_context context;				//kontext
	cl_command_queue commandQueue;	//fronta pozadavku
	cl_program program;				//program
	Errors errorController;			//spravce vyjmek

	////////////////////////////
	// Prevzato ze cviceni GMU
	////////////////////////////

	/*
	 * Nacteni zdrojoveho programu pro kernely. 
	 * @cFilename - cesta k souboru	 
	 */
	char* LoadProgSource(const char* cFilename);
};

